import Form from './form'
import Input from './input'
import Menu from './menu'
import Message from './message'
import Editor from './editor'
import Calendar from './calendar'
import Radio from './radio'
import Upload from './upload'
import Tag from './tag'
import Loading from './loading'
import Modal from './modal'
import Tab from './tab'
import Button from './button'
import ImgPreview from './img-preview'

const components = {
  Form,
  FormItem: Form.Item,
  Input,
  Menu,
  SubMenu: Menu.SubMenu,
  MenuItem: Menu.MenuItem,
  Message,
  Editor,
  Calendar,
  Radio,
  RadioGroup: Radio.RadioGroup,
  Upload,
  Tag,
  Loading,
  Modal,
  Tab,
  TabPanel: Tab.TabPanel,
  Button,
  ImgPreview
}

const install = function(Vue) {
  if (install.installed) return

  Object.keys(components).forEach(key => {
    Vue.component(key, components[key])
  })

  Vue.prototype.$Message = Message
  Vue.prototype.$Loading = Loading
  Vue.prototype.$Modal = Modal
  Vue.prototype.$ImgPreview = ImgPreview
}

export default {
  // 导出的对象必须具有 install，才能被 Vue.use() 方法安装
  install,
  // 以下是具体的组件列表
  ...components
}
